package com.baipiao.permission.backend.controller.sys;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.baipiao.permission.backend.entity.response.Res;
import com.baipiao.permission.backend.entity.response.ResData;

/**
 * @author Livi Luo
 */
@RestController
@Tag(name = "登录/退出接口", description = "用于登录和获取权限，退出系统等操作")
public class AuthController {

    @Operation(summary = "获取登录用户信息，所有角色可以访问")
    @RequestMapping(value = "getLoginUser", method = RequestMethod.GET)
    public Res getLoginUser(Authentication authentication) {
        UserDetails userDetails = (UserDetails) authentication.getPrincipal();
        return ResData.success(userDetails);
    }

    @Operation(summary = "登录")
    @RequestMapping(value = "login", method = RequestMethod.POST)
    public void login(String username, String password) {
    }

    @Operation(summary = "退出")
    @RequestMapping(value = "logout", method = RequestMethod.POST)
    public void hello() {
    }

}
